/*
 * Inode.cpp
 *
 *  Created on: Apr 16, 2012
 *      Author: jaap
 */

#include "Inode.h"
#include "FileSystem.h"

Inode::Inode(int number, byte *data) {
	this->number = number;
	mode = getshort(data, 0);
	linkcount = getshort(data, 2);
	filesize = getlong(data, 8);
	usecount = 1;
}

int Inode::getNumber() {
	return number;
}

int Inode::getMode() {
	return mode;
}

int Inode::getUsecount() {
	return usecount;
}

long Inode::getFilesize() {
	return filesize;
}

int Inode::getLinkcount() {
	return linkcount;
}

void Inode::increaseUsecount() {
	usecount++;
}

void Inode::decreaseUsecount() {
	assert(usecount > 0);
	usecount--;
}

void Inode::increaseLinkcount() {
	linkcount++;
}

void Inode::decreaseLinkcount() {
	assert(linkcount > 0);
	linkcount--;
}
